package leetcode.力扣竞赛.第389场周赛;

import java.util.HashSet;
import java.util.Set;

/**
 * description:
 *
 * @author 颜真明
 * @date 2024/3/24  10:41
 */
public class Solution3083 {
    public static void main(String[] args) {
        System.out.println(isSubstringPresent("abcd"));
    }
    public static boolean isSubstringPresent(String s) {
        Set<String> set = new HashSet<>();
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < s.length() - 1; i++) {
            String subStr = s.substring(i, i + 2);
            set.add(subStr);
            str.append(s.charAt(s.length() - i - 1));
        }
        str.append(s.charAt(0));
        for (int i = 0; i < str.length() - 1; i++) {
            String subStr = str.substring(i, i + 2);
            if (set.contains(subStr)) {
                return true;
            }
        }
        return false;
    }
}
